(function () {

    amplify.request.decoders.appEnvelope =
        function (data, status, xhr, success, error) {
            if (status != "error") {
                if (data.status === "success") {
                    success(data.data);
                } else {
                    log.error(data.message);
                    error(data.message);
                }
            }
            else {
                log.error("unknown error on amplify request");
            }
        };

    amplify.request.define("models", "ajax", {
        url: "/api/businessmodels",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        type: "GET",
        decoder: "appEnvelope"
    });

    amplify.request.define("createModel", "ajax", {
        url: "/api/businessmodels",
        type: "POST",
        decoder: "appEnvelope"
    });

}).call(this);
